const path = require('path')
const webpack = require('webpack')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')

const resolve = dir => path.join(__dirname, '..', dir)

module.exports = {
    entry: {
        app: ['./src/main.js', 'webpack-hot-middleware/client?reload=true'],
        b: './src/b.js'
        // a:['./src/a.js', 'webpack-hot-middleware/client?reload=true']
    },
    output: {
        path: resolve('dist'),
        filename: '[name].[hash].js',
        publicPath: ''
    },
    resolve: {
        extensions: ['.js', '.json']
    },
    module: {
        rules: [{
            test: /\.js$/,
            loader: 'babel-loader',
            query: {
                presets: ['env'],
                env: {
                    production: {
                        presets: ["minify"]
                    }
                }
            },
            include: resolve('src')
        },{
            test: /\.css$/,
            use: ['style-loader', 'css-loader']
        },{
            test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
            loader: 'url-loader'
        }]
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new CleanWebpackPlugin(['dist']),
        new HtmlWebpackPlugin({
            title: 'boom'
        }),
        new webpack.optimize.CommonsChunkPlugin({
            name: 'b',
        }),
        new webpack.optimize.CommonsChunkPlugin({
            name: 'manifest',
        }),
        new webpack.NoEmitOnErrorsPlugin()
    ]
}